import 'package:amway_superapp_creator_plugin/utils/sp_util.dart';
import 'package:intl/intl.dart';
import 'package:zhugeio/zhugeio.dart';

final String amwayIdKey = 'zhuge_amway_id_key';
final String amwayAccesstypeKey = 'zhuge_accesstype_key';

class ZhugeIdentifyAnalysis {
  //用户身份确认
  static bindUser(
      {amwayid,
        icon,
        nickname,
        openid,
        unionid,
        adaid,
        accesstype,
        gender,
        city}) async {
    var time = new DateTime.now();
    var formatter = new DateFormat('yyyy-MM-dd HH:mm:ss');
    String loginTime = formatter.format(time);

    SpUtil.setData(amwayIdKey, amwayid);
    SpUtil.setData(amwayAccesstypeKey, accesstype);
    Future.delayed(Duration(seconds: 0), () {
      Zhugeio.identify(amwayid, {
        "用户类型": accesstype,
        "ADAID": adaid,
        "OpenID": openid,
        "unionID": unionid,
        "signupDate": loginTime,
        "昵称": nickname,
        "头像": icon,
        "性别": gender,
        "城市": city,
      });
    });
  }
}